#!/usr/local/bin/bash
workdir=$(
    # shellcheck disable=SC2046
    cd $(dirname "$0") || exit
    pwd
)

configRootDir=$HOME/Nutstore\ Files/我的坚果云/config-sys
universalConfigName='config-universal'
macConfigName='config-mac'
universalConfigDir=$configRootDir/$universalConfigName
macConfigDir=$configRootDir/$macConfigName
#家目录放置的Docker数据目录和备份目录
dockerBakName='DockerData/DockerBak'
localRepoDir="$HOME/GitRepository"

cd
rm -r $gitRepository
rm -r .gradle
rm -r .docker
rm -r .ngrok
rm -r .config/ranger
rm -r .m2/repository
rm -r DockerData/DockerBak

rm -r .vim
rm -r .config
rm -r .config/iterm2
rm -r .config/nvim
rm -r .config/ranger

mkdir -p $gitRepository
mkdir -p .gradle
mkdir -p .docker
mkdir -p .ngrok
mkdir -p .config/ranger
mkdir -p .m2/repository
mkdir -p DockerData/DockerBak
#------------linux会通用的文件夹----------------
mkdir -p .vim
mkdir -p .config
mkdir -p .config/iterm2
mkdir -p .config/nvim
mkdir -p .config/ranger
#------------------mac和linux通用的配置(universal指的是系统间的通用)(common指的是linux各大发行版之间的通用)------------------
#vim及neovim配置(方案1)
#vim配置

ln -snf $universalConfigDir/.vim/* ~/.vim
ln -snf $universalConfigDir/.vim/* ~/.config/nvim
ln -sf $universalConfigDir/.config/nvim/init.vim ~/.config/nvim
ln -sf $universalConfigDir/.config/nvim/init.vim ~/.vimrc

#ranger配置
ln -snf $universalConfigDir/.config/ranger/* ~/.config/ranger
#ngrok内网穿透配置
ln -snf $universalConfigDir/.ngrok ~
#配置通用家目录包含(mycli)
ln -sf $universalConfigDir/config-home/.* ~
#-------------mac独有的配置-----------------------

#~ ln -snf ~/Documents/_posts
#macvim输入法切换
#Ln -sf $macConfigDir/vim-switch-input/xkbswitch-macosx/bin/xkbswitch /usr/local/bin
#Ln -sf $macConfigDir/vim-switch-input/libxkbswitch-macosx/bin/libxkbswitch.dylib /usr/local/lib/
#mac环境变量配置
rm -rf $macConfigDir/config-home/.idea
ln -snf $macConfigDir/config-home/.* ~
#gradle配置
ln -sf $macConfigDir/.gradle/* ~/.gradle/
#docker配置
ln -sf $macConfigDir/.docker/* ~/.docker/
#备份sql
ln -snf $universalConfigDir/useful-sh/bak_docker_mysql.sh ~/DockerData/DockerBak/
#仓库软连接配置
ln -snf ~/Nutstore\ Files/我的坚果云/some-sh $localRepoDir
ln -snf $configRootDir/* $localRepoDir
#maven仓库及阿里源配置(这里千万不要把整个.m2软链接过去,不然你的坚果云会存储所有仓库的jar包=.=)
ln -sf $macConfigDir/.m2/settings.xml ~/.m2/
ln -sf $macConfigDir/.m2/repository/archetype-catalog.xml ~/.m2/repository/
#docker镜像源配置
ln -sf $macConfigDir/$dockerBakName/bakDockerMysql.sh ~/$dockerBakName

#lazygit配置
ln -snf $universalConfigDir/.config/lazygit ~/.config
ln -snf $universalConfigDir/.config/lazygit ~/Library/Application\ Support/
#item2配置
#mvln ~/Library/Preferences/com.googlecode.iterm2.plist $macConfigDir/.config/iterm2
ln -sf $macConfigDir/.config/iterm2/com.googlecode.iterm2.plist ~/Library/Preferences/com.googlecode.iterm2.plist
# idea配置
#确保安装了idea,这一步声明idea的配置文件在哪里软连接到ideaApp包内
ln -snf $universalConfigDir/.IntelliJIdea ~
ln -snf $macConfigDir/idea.properties /Applications/IntelliJ\ IDEA.app/Contents/bin/idea.properties
